﻿using System;
using System.Text;
using TI_BLE_HCI_ClientLib.GenericHCIEntities;
using TI_BLE_HCI_ClientLib.HCIBaseEntities;

namespace TI_BLE_HCI_ClientLib.HCIEvents
{
    public class HCIEvent_ATT_Read_By_Group_Type_Request : HCIEvent_GATT_Base_Event
    {
        public ushort StartHandle
        {
            get
            {
                switch (base.PduLen)
                {
                    case 6:
                    case 20:
                        return (ushort)(base.Pdu[0] + (base.Pdu[1] << 8));
                }

                throw new ArgumentException("PduLen!=6 && PduLen!=20");
            }
        }

        public ushort EndHandle
        {
            get
            {
                switch (base.PduLen)
                {
                    case 6:
                    case 20:
                        return (ushort)(base.Pdu[2] + (base.Pdu[3] << 8));
                }

                throw new ArgumentException("PduLen!=6 && PduLen!=20");
            }
        }

        public byte[] GroupType16
        {
            get
            {
                switch (base.PduLen)
                {
                    case 20:
                        byte[] grpType = new byte[16];
                        Array.Copy(base.Pdu, 4, grpType, 0, grpType.Length);
                        return grpType;

                    default:
                        return null;

                }

            }
        }

        public ushort GroupType
        {
            get
            {
                switch (base.PduLen)
                {
                    case 6:
                        return (ushort)(base.Pdu[4] + (base.Pdu[5] << 8));

                    default:
                        return 0xffff;

                }

            }
        }

        public HCIEvent_ATT_Read_By_Group_Type_Request(HCIVendorSpecificEventHostErrorCode status,
            ushort connHandle, byte pduLen, byte[] pdu) : base(status, connHandle, pduLen, pdu)
        {
        }
    }
}
